﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace SimpleRest.Core
{
    /// <summary>
    /// Interface that should be implemented to create a new media type formatter for a Configuration object.
    /// </summary>
    public interface IMediaTypeFormatter
    {
        /// <summary>
        /// A list of supported media types.  These are usually values associated to Accept or Content-Type headers.
        /// </summary>
        IEnumerable<string> SupportedMediaTypes { get; }

        /// <summary>
        /// Determines how to serialize an object in the event that this media type formatter was selected.
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        Stream Serialize(object obj);
        /// <summary>
        /// Determines how to deserialize an object in the event that this media type formatter was selected.
        /// </summary>
        /// <param name="item"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        object DeSerialize(Stream item, Type type);

        /// <summary>
        /// Indicates to the pipeline if this media type formatter has the ability to serialize.
        /// </summary>
        bool CanSerialize(Type type);
        /// <summary>
        /// Indicates to the pipeline if this media type formatter has the ability to deserialize.
        /// </summary>
        bool CanDeserialize(Type type);
    }
}
